e4f576df19494b40071011438a364e3f6a33730d,ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java,RRDRequest,populateResource,#Resource#GangliaMetric#,467
Before Change
* @param gangliaMetric the Ganglia metrics
*/
private void populateResource(Resource resource, GangliaMetric gangliaMetric) {
Set<String> propertyIdSet = metrics.get(gangliaMetric.getMetric_name());
if (propertyIdSet != null) {
Map<String, PropertyInfo> metricsMap = getComponentMetrics().get(getComponentName(resource));
if (metricsMap != null) {
for (String propertyId : propertyIdSet) {
if (propertyId != null) {
if (metricsMap.containsKey(propertyId)){
resource.setProperty(propertyId, getValue(gangliaMetric, temporalInfo != null));
}
}
}
After Change
* @param gangliaMetric the Ganglia metrics
*/
private void populateResource(Resource resource, GangliaMetric gangliaMetric) {
String metric_name = gangliaMetric.getMetric_name();
Set<String> propertyIdSet = metrics.get(metric_name);
List<String> parameterList = new LinkedList<String>();
if (propertyIdSet == null) {
for (Map.Entry<String, Set<String>> entry : metrics.entrySet()) {
String key = entry.getKey();
Pattern pattern = Pattern.compile(key);
Matcher matcher = pattern.matcher(metric_name);
if (matcher.matches()) {
propertyIdSet = entry.getValue();
// get parameters
for (int i = 0; i < matcher.groupCount(); ++i) {
parameterList.add(matcher.group(i + 1));
}
break;
}
}
}
if (propertyIdSet != null) {
Map<String, PropertyInfo> metricsMap = getComponentMetrics().get(getComponentName(resource));
if (metricsMap != null) {
for (String propertyId : propertyIdSet) {
if (propertyId != null) {
if (metricsMap.containsKey(propertyId)){
if (propertyId.matches(".*\\$\\d+.*")) {
int i = 1;
for (String param : parameterList) {
propertyId = propertyId.replace("$" + i, param);
++i;
}
}
resource.setProperty(propertyId, getValue(gangliaMetric, temporalInfo != null));
}
}
}